package com.birdy.jwt.code;

import javax.servlet.http.HttpServletResponse;


/**
 * @author birdy
 */
public enum JWTResponseCode {
    /**
     * 成功
     */
    SUCCESS_CODE(HttpServletResponse.SC_OK, "validity token"),
    TOKEN_TIMEOUT_CODE(HttpServletResponse.SC_UNAUTHORIZED, "expired token"),
    NO_AUTH_CODE(HttpServletResponse.SC_NOT_FOUND, "没有找到匹配的Token信息，无法进行服务访问！");
    private int code;
    private String message;
    private JWTResponseCode(int code, String message) {
        this.code = code;
        this.message = message;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    @Override
    public String toString() {  // 直接将数据以JSON的形式返回
        return "{\"code\":" + this.code + ",\"message\":" + this.message + "}";
    }
}
